using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
namespace Microsoft.Expression.Media
{
	public sealed class GeometryEffectConverter : TypeConverter
	{
		private static Dictionary<string, GeometryEffect> registeredEffects;
		public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
		{
			return typeof(string).IsAssignableFrom(sourceType);
		}
		public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
		{
			return typeof(string).IsAssignableFrom(destinationType);
		}
		public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
		{
			string text = value as string;
			GeometryEffect geometryEffect;
			if (text != null && GeometryEffectConverter.registeredEffects.TryGetValue(text, ref geometryEffect))
			{
				return geometryEffect.CloneCurrentValue();
			}
			return null;
		}
		public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
		{
			if (typeof(string).IsAssignableFrom(destinationType))
			{
				object key;
				using (Dictionary<string, GeometryEffect>.Enumerator enumerator = GeometryEffectConverter.registeredEffects.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						KeyValuePair<string, GeometryEffect> current = enumerator.get_Current();
						if ((current.get_Value() == null) ? (value == null) : current.get_Value().Equals(value as GeometryEffect))
						{
							key = current.get_Key();
							return key;
						}
					}
					goto IL_71;
				}
				return key;
			}
			IL_71:
			return null;
		}
		static GeometryEffectConverter()
		{
			// Note: this type is marked as 'beforefieldinit'.
			Dictionary<string, GeometryEffect> dictionary = new Dictionary<string, GeometryEffect>();
			dictionary.Add("None", GeometryEffect.DefaultGeometryEffect);
			dictionary.Add("Sketch", new SketchGeometryEffect());
			GeometryEffectConverter.registeredEffects = dictionary;
		}
	}
}
